//声明: 该文件需要 swiper,jqueryui,common,toast,jquery

require(["config"], function(config) {
	require(["jquery.ui", "jquery", "sw", "toast", "my.hover"], function(jqui, jq, sw, t, mh) {

//		关闭广告
		$(".guanbi").click(function(){
			$("#guanggao").hide();
		})
		//下拉菜单
		$(".li1").mouseover(function(){
			$("#ao_list").css({"display":"block"});
			$(".sanjiaoxing").css({"display":"block"});
			
			
			$("#ao_list").mouseover(function(){
			$("#ao_list").css({"display":"block"});
			$(".sanjiaoxing").css({"display":"block"});
			
			
		})
			
		})
		$("#ao_list").mouseout(function(){
			$("#ao_list").css({"display":"none"});
			$(".sanjiaoxing").css({"display":"none"});
		})
		$(".li1").mouseout(function(){
			$("#ao_list").css({"display":"none"});
			$(".sanjiaoxing").css({"display":"none"});
		})
		

		//菜单
		function creatCategory(data) {
			for(var i in data) {
				$('#banner_left_bottom').append("<div class='navleft'><a href='nvzhuang.html'>" + data[i].aaa_1 + data[i].aaa_2 + "").append("<div class='nav-layer'>");
				for(var j in data[i].aaa_3) {
//									console.log(data[i].aaa_3[j])
					$('.nav-layer').last().append("<div class='ft'><dt><a>" + data[i].aaa_3[j].aaa_4_a + "");
					for(var k in data[i].aaa_3[j].aaa_4_b) {
						$('.ft').last().append("<dd><a href='nvzhuang.html'>" + data[i].aaa_3[j].aaa_4_b[k] + "")
					}
				}
			}

			var navleft = document.getElementsByClassName("navleft");
			var navlayer = document.getElementsByClassName("nav-layer");
			for(let i = 0; i < navleft.length; i++) {
				navleft[i].onmouseover = function() {
					
					

					for(let j = 0; j < navleft.length; j++) {
						navleft[j].style.background = "#fff";
						navlayer[j].style.display = "none";
					}
					this.style.background = "#F5F5F5";
					navlayer[i].style.display = "block";
					

					navlayer[i].onmouseleave = function() {
						navlayer[i].style.display = "none";
						navleft[i].style.background = "#fff";
					}
					navlayer[i].onmouseover = function() {
						navlayer[i].style.display = "block";
						navleft[i].style.background = "#f5f5f5";
					}
					navleft[i].onmouseleave = function() {
						navlayer[i].style.display = "none";
						navleft[i].style.background = "#fff";
					}
				}

			}

		}
		$.get("json1/banner.json", function(data) {
			creatCategory(data);
		})

		
	jq("#search").autocomplete({
			source: function(request, response) {
				$.ajax({
					url: "http://suggestion.baidu.com/su",
					dataType: "jsonp",
					data: {
						wd : request.term
					},
					jsonp: "cb",
					success: function(data) {
						console.log(data);
					response(data.s);
//				$(".form1").last().append("<div class='neirong1'>"+data.s+"");
				
					}
				});
			},
			select : function(event, ui) {
				console.log(ui.item.label);
				
			}
		});

	});

})